package com.liuyi.netty.im.lychat.im;

import com.github.pagehelper.PageHelper;
import com.liuyi.netty.im.commons.codes.data.event.Message;
import com.liuyi.netty.im.commons.codes.data.event.message.playload.Playload;
import com.liuyi.netty.im.lychat.modular.entity.MessageUserRecords;
import com.liuyi.netty.im.lychat.modular.enums.MessageStatus;
import com.liuyi.netty.im.lychat.modular.service.IMessageUserRecordsService;
import com.liuyi.netty.im.server.handle.service.MessageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 消息接口实现
 *
 * @author Mr.Fmy
 * @since 2021/12/25
 */
@Service
public class LychatMessageService implements MessageService {

    @Resource
    private IMessageUserRecordsService messageUserRecordsService;

    @Override
    public List<Message<? extends Playload>> listNotSendByUser(String userId) {
        PageHelper.startPage(1, 100, false);
        List<MessageUserRecords> messageUserRecords = messageUserRecordsService.listByUserIdAndStatus(userId, MessageStatus.NOT_SEND);
        return messageUserRecordsService.wrapperMessage(messageUserRecords);
    }
}
